package org.tradeinterceptor.modular.strategy.modules;

import org.tradeinterceptor.modular.strategy.ForexSignal;
import org.tradeinterceptor.modular.strategy.StrategyModule;

import com.riflexo.charting.api.AbstractEasyCalculator;
import com.riflexo.charting.api.StockIndicator;

public class AdxStrategyModule implements StrategyModule {
	
	private StockIndicator<Object> ADX;
	private int adxPeriod;

	public AdxStrategyModule(int period) {
		this.adxPeriod = period;
	}
	
	@Override
	public void setPosition(ForexSignal signal) {
		// this is a non positional module
	}
	
	@Override
	public ForexSignal getSignal() {
		// TODO Auto-generated method stub
		ForexSignal signal = ForexSignal.STAND_ASIDE;
		double val = ADX.get();
		// If the ADX is < 15, then breakout might come soon..
		if(val >= 20  && val <= 40){
			signal = ForexSignal.MOMENTUM;
		}
		return signal;
	}

	@Override
	public void declare(AbstractEasyCalculator parent) {
		// TODO Auto-generated method stub
		ADX = parent.getStockIndicatorUtil().declareDMI_ADX("adx", adxPeriod);

	}
	
	@Override
	public void close() {
		// TODO Auto-generated method stub
		
	}

}
